/*****************************************************************//**
 * \file   Camera.h
 * \brief  该文件是Camera.cpp的头文件，主要处理摄像头开关及数据处理相关代码
 * 
 * \author Administrator
 * \date   July 2021
 * \modify by Administrator
 * \date   July 2021

 *********************************************************************/
#pragma once

#include "opencv2/opencv.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/core.hpp"
#include "opencv2/imgproc/types_c.h"
#include <iostream>
using namespace std;

class Camera
{
private:
	
	static int iCameraCount; //相机个数
	bool bOpened;
public:
	Camera();
	~Camera();
	bool open(int index);
	void close();
	cv::Mat read();
	static int getCameraCount()
	{
		if (iCameraCount > 0)
		{
			return  iCameraCount;
		}
		else {
			cv::VideoCapture _capture;
			while (_capture.open(iCameraCount, cv::CAP_DSHOW))
			{
				iCameraCount++;
				_capture.release();
			}
			return  iCameraCount;
		}
	}
};
